package com.act.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import com.act.dao.IContractManagementDao;
import com.act.domain.ContractManagement;
import com.act.dto.PagerDTO;
import com.act.service.api.IContractManagementService;
import com.act.vo.PagerVo;

@Service
public class ContractManagementServiceImpl implements IContractManagementService{

	@Resource
	private IContractManagementDao contractManagementDao; 

	@Override
	public void delete(int id) {
		contractManagementDao.delete(id);
	}

	@Override
	public void add(ContractManagement contractManagement) {
		contractManagementDao.add(contractManagement);
	}

	@Override
	public void update(ContractManagement contractManagement) {
		contractManagementDao.update(contractManagement);
	}

	@Override
	public ContractManagement getById(@Param("id")int id) {
		return contractManagementDao.getById(id);
	}

	@Override
	public PagerVo<Map> getAll(@Param("pagerDTO")PagerDTO pagerDTO) {
		int startIndex = pagerDTO.getStartIndex();
		int endIndex = pagerDTO.getEndIndex();
		int totalCounts = contractManagementDao.getCounts();
		List<Map> list = contractManagementDao.getAll(startIndex, endIndex);
		PagerVo<Map> pagerVo = new PagerVo<>(pagerDTO.getPageIndex(),pagerDTO.getPageSize(),totalCounts,list);

		return pagerVo;
	}

}
